$(function () {
    var form = new xhForm($('#xh_form'));
    form.parse();
    $('[name=sMonth]').val(getNowMonth());
    $('[name=iType]').val(xhTool.getQuery('type'));
    $('[name=iTargetId]').select2();

    if(info!=null){
        form.fill(info);
    }

    $('#bt_modal_confirm' , parent.document).click(function () {
        if ($('[name=iGrade]').val() > 5) {
            window.top.xhTop.showError('错误','成绩不能大于5');
            xhExtra.setBtnNormal($(this));
            return false;
        }
        form.submit('grade/saveGrade',{},function (res) {
            window.top.xhTop.showSuccess(res.msg);
            window.top.xhTop.getActiveFrame()['caseFrame'].obj.dataGrid.reload();
            window.top.xhTop.getActiveFrame()['weekFrame'].obj.dataGrid.reload();
            window.top.xhTop.closeModal();
        })
    })
});

function getNowMonth() {
    var date = new Date();
    var month = date.getMonth()+1 ;
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    return  date.getFullYear()+'-'+ month;
}